package com.cly.common.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@ConditionalOnClass(RabbitTemplate.class)
public class ErrorMessageListener {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "error.queue"),
            exchange = @Exchange(name = "error.direct"),
            key = "error"
    ))
    public void errorMessageListener(Message message) {
        log.error("error.queue 接收到异常消息：{}" + message.getBody());

    }
}
